package lq.demo.springbootmybatis.demo.service.impl;

import lq.demo.springbootmybatis.demo.entity.User;
import lq.demo.springbootmybatis.demo.mapper.UserMapper;
import lq.demo.springbootmybatis.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public List<User> getUser() {
        return userMapper.getUser();
    }

    @Override
    public int addBatchUser(List<User> userList) {
        return userMapper.addBatchUser(userList);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int deleteUser(User user) {
        return userMapper.deleteUser(user);
    }

    @Transactional
    @Override
    public int error(User user) {
        deleteUser(user);
        int i = 1 / 0;
        return 0;
    }


}
